#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_define_exception0.py
# author:jackiex
# datetime:2022/3/10 9:25
# software: PyCharm

'''
    this is function  description 
'''
class ShortInputException(Exception):
    def __init__(self, length, atleast):
        self.length = length
        self.atleast = atleast

def main():
    try:
        s = input('请输入 --> ')
        if len(s) < 3:
            # raise引发一个你定义的异常
            raise ShortInputException(len(s), 3)
    except ShortInputException as result:#x这个变量被绑定到了错误的实例
        print('ShortInputException: 输入的长度是 %d,长度至少应是 %d'% (result.length, result.atleast))
    else:
        print('没有异常发生')
main()
